package com.dmp.pushlogs.bolt;

import com.dmp.common.date.DateUtils;
import com.dmp.storm.bolt.BaseMapBolt;

import java.util.Date;
import java.util.Map;

/**
 * @ClassName customBolt
 * @Description
 *
 * @author sunzy
 * @date 2016年4月14日 下午7:49:23
 * @version 1.0
 *
 */
public class InputCustomBolt extends BaseMapBolt {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1797212540641047767L;

	
	@Override
	public Map<String, Object> process(Map<String, Object> map) {
		Map<String, Object> record = map;
		try {
			String timeStr = (String) map.get("fe_time");
			long timeL = Long.valueOf(timeStr).longValue();
			Date date = new Date(timeL);
			timeStr = DateUtils.formatDate(date, "yyyyMMddHHmmss");
			record.put("fe_time", timeStr);

			//日期类型规则化
			String logTime = (String) map.get("input_time");
			timeL = Long.valueOf(logTime).longValue();
			Date dateLog = new Date(timeL);
			logTime = DateUtils.formatDate(dateLog, "yyyyMMddHHmmss");
			record.put("input_time", logTime);

			// 其它时间
			record.put("hour", DateUtils.formatDate(date, "yyyyMMddHH"));
			record.put("hour_h", DateUtils.formatDate(date, "HH"));
			record.put("day", DateUtils.formatDate(date, "yyyyMMdd"));
			record.put("day_d", DateUtils.formatDate(date, "dd"));
			record.put("month", DateUtils.formatDate(date, "yyyyMM"));
			record.put("month_m", DateUtils.formatDate(date, "MM"));
			
			//日志时间
			record.put("log_date", DateUtils.formatDate(dateLog, "yyyy/MM/dd HH:mm:ss"));
		} catch (Exception e) {
			System.err.println(map);
			e.printStackTrace();
			
			return null;
		}
		return record;
	}


}
